import { http } from "@/utils/http";

export interface MusicVO {
  id: number;
  musicId: string;
  musicCoverUrl: string;
  musicName: string;
  musicAuthor: string;
  musicAlbum: string;
  musicPublisDate: string;
  musicPushDate: string;
  musicLength: string;
  musicTypeId: number;
  musicUrl: string;
  status: string;
}

export const musicManageAPI = () => {
  const getMusic = (): any => {
    return http.get("music/page?key=${name}");
  };

  const getMusicByName = (name: string, page: number, rows: number): any => {
    return http.get(`music/page?key=${name}&page=${page}&rows=${rows}`);
  };

  const addMusic = (data: MusicVO): any => {
    return http.post("music/addMusic", data);
  };

  const updateMusic = (data: MusicVO): any => {
    return http.put("music", data);
  };

  const deleteMusic = (data: MusicVO): any => {
    return http.delete("music", { data });
  };

  // 获得所有歌曲类型
  const getmusicType = (): any => {
    return http.get(`music/type/all`)
  }

  return {
    getMusic,
    getMusicByName,
    addMusic,
    updateMusic,
    deleteMusic,
    getmusicType
  };
};